<template>
  <div class="chart-body" ref="chartRef"></div>
</template>

<script lang="ts">
export default {
  name: "ProgressChart",
};
</script>

<script lang="ts" setup>
import { ref, onMounted } from "vue";
import * as echarts from "echarts";

const chartRef = ref();

//需要在组件挂载完获取DOM节点
onMounted(() => {
  const myEcharts = echarts.init(chartRef.value);
  const option = {
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      data: ["百分比"],
      show: false,
    },
    series: {
      name: "用户增长量",
      type: "bar",
      data: [33],
      //柱形颜色
      itemStyle: {
        color: "#9acd32",
      },
      barWidth: 10,
      //柱形背景色
      showBackground: true,
      //提示文字
      label: {
        show: true,
        position: "right", //显示在数据右边v
        formatter: "|", //显示的内容
        color: "#9acd32", //显示的颜色
      },
    },
    tooltip: {
      //坐标轴
      trigger: "axis",
      axisPointer: {
        type: "line",
      },
    },
    grid: {
      left: 0,
      right: 0,
      top: 0,
      bottom: 0,
    },
  };
  myEcharts.setOption(option);
});
</script>

<style scoped>
.chart-body {
  height: 100%;
}
</style>
